//----------------------------------------------------------------------------
//  ,-.
// /_\___ ,   Ninja Framework
// '  ___\    (C) Riccardo Capra - http://riccar.do
//  //   \\
//----------------------------------------------------------------------------
//  This program is free software: you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
//----------------------------------------------------------------------------

#ifndef NJ_DEBUG_SYSTEM_TEST_IMPLEMENTATION_H
#	define NJ_DEBUG_SYSTEM_TEST_IMPLEMENTATION_H

#	include "NjExample01.h"

	/// \brief A special implementation of NjDebugSystem
	///
	/// This implementation does not trigger hardware breakpoints
	/// but stores trigger events in \em m_bWasTriggeredBreakpoint so that later can be checked if a breakpoint would have been triggered
	class NjDebugSystemTestImplementation : public NjDebugSystem::Implementation
	{
	public:
		/// \brief Creates an NjDebugSystemTestImplementation and stores a previous implementation to be proxied
		NjDebugSystemTestImplementation(NjDebugSystem::Implementation * pPrevious=NJ_NULL);
		NJ_TRIVIAL_VIRTUAL_DESTRUCTOR(NjDebugSystemTestImplementation);

		/// \brief Return NJ_TRUE if a break point was triggered
		///
		/// It also resets its internal state. If it is queried again, it will return NJ_FALSE
		NjBool WasTriggeredBreakpoint() const;

	protected:
		/// \brief Stores if this function was called, but does not trigger a real hardware breakpoint
		/// \return NJ_TRUE
		virtual NjBool TriggerBreakPoint();

		/// \brief Returns m_spPrevious->IsDebuggerAttached() or NJ_FALSE if m_spPrevious is NJ_NULL
		virtual NjBool IsDebuggerAttached();

		/// \brief Calls m_spPrevious->WriteToDebugConsole(szText)
		/// \return NJ_FALSE if m_spPrevious is NJ_NULL or the value returned by WriteToDebugConsole call
		virtual NjBool WriteToDebugConsole(NjCharA const * szText);

	private:
		/// \brief The NjDebugSystem::Implementation that will be proxied
		NjSmartPtr<NjDebugSystem::Implementation> m_spPrevious;

		/// \brief Stores if TriggerBreakPoint was called
		mutable NjBool m_bWasTriggeredBreakpoint;

		NJ_DISABLE_COPY(NjDebugSystemTestImplementation);
	};

#		include "NjDebugSystemTestImplementation_inline.h"

#endif // NJ_DEBUG_SYSTEM_TEST_IMPLEMENTATION_H
